﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TableParsers;

namespace SpeakupTests.WebLayer.ClassTypes
{
    [TestClass]
    public class ClassNameParserTests
    {
        /// <summary>
        /// Page on which attended, missed and cancelled classes are shown.
        /// All examples in this test are from this page.
        /// </summary>
        [TestMethod]
        public void AttendedAndCancelledClassesParser()
        {
            Dictionary<String, ClassName> classes = new Dictionary<string, ClassName>();

            //group classes
            classes["CC-GC 8 - RED"]    = new ClassName("CC-GC 8 - RED",    "Red",      ClassType.Group);
            classes["CC-GC 8 - YELLOW"] = new ClassName("CC-GC 8 - YELLOW", "Yellow",   ClassType.Group);
            classes["CC-GC 8 - ORANGE"] = new ClassName("CC-GC 8 - ORANGE", "Orange",   ClassType.Group);
            classes["CC-GC 8 - VIOLET"] = new ClassName("CC-GC 8 - VIOLET", "Violet",   ClassType.Group);
            classes["CC-GC 8 - BLUE"]   = new ClassName("CC-GC 8 - BLUE",   "Blue",     ClassType.Group);
            classes["CC-GC 6 - RED"]    = new ClassName("CC-GC 6 - RED",    "Red",      ClassType.Group);
            classes["CC-GC 7 - YELLOW"] = new ClassName("CC-GC 7 - YELLOW", "Yellow",   ClassType.Group);
            classes["CC-GC 9 - ORANGE"] = new ClassName("CC-GC 9 - ORANGE", "Orange",   ClassType.Group);
            classes["CC-GC 12 - VIOLET"] = new ClassName("CC-GC 12 - VIOLET", "Violet", ClassType.Group);
            classes["CC-GC 14 - BLUE"]  = new ClassName("CC-GC 14 - BLUE",  "Blue",     ClassType.Group);

            //club classes
            classes["CA-FAMILY CLUB"]       = new ClassName("CA-FAMILY CLUB",       "Family",       ClassType.Club);
            classes["CA-ARCHITECTURE CLUB"] = new ClassName("CA-ARCHITECTURE CLUB", "Architecture", ClassType.Club);
            classes["CA-ART CLUB"]          = new ClassName("CA-ART CLUB",          "Art",          ClassType.Club);
            classes["CA-PHRASAL VERBS CLUB"] = new ClassName("CA-PHRASAL VERBS CLUB", "Phrasal Verbs", ClassType.Club);
            classes["CA-COOKING CLUB"]      = new ClassName("CA-COOKING CLUB",      "Cooking",      ClassType.Club);
            classes["CA-JOBS & WORK CLUB"]  = new ClassName("CA-JOBS & WORK CLUB",  "Jobs & Work",  ClassType.Club);
            classes["CA-MEDICAL CLUB"]      = new ClassName("CA-MEDICAL CLUB",      "Medical",      ClassType.Club);
            classes["CA-BUSINESS CLUB"]     = new ClassName("CA-BUSINESS CLUB",     "Business",     ClassType.Club);
            classes["CA-TOP TENS CLUB"]     = new ClassName("CA-TOP TENS CLUB",     "Top Tens",     ClassType.Club);
            classes["CA-SPORT CLUB"]        = new ClassName("CA-SPORT CLUB",        "Sport",        ClassType.Club);
            classes["CA-TRAVELLING CLUB"]   = new ClassName("CA-TRAVELLING CLUB",   "Travelling",   ClassType.Club);

            //bussiness club classes
            classes["BW - LEVEL 5/6 - WEEK 5"] = new ClassName("BW - LEVEL 5/6 - WEEK 5", "Business", ClassType.Business);
            classes["BW - LEVEL 5/6 - WEEK 3"] = new ClassName("BW - LEVEL 5/6 - WEEK 3", "Business", ClassType.Business);
            classes["BW - LEVEL 5/6 - WEEK 2"] = new ClassName("BW - LEVEL 5/6 - WEEK 2", "Business", ClassType.Business);            
            
            //workshops
            classes["WS-GRAMMAR WORKSHOP"]      = new ClassName("WS-GRAMMAR WORKSHOP", "Grammar", ClassType.Grammar);
            classes["WS-WRITING WORKSHOP"]      = new ClassName("WS-WRITING WORKSHOP", "Writing", ClassType.Writing);
            classes["WS-READING & VOCABULARY WORKSHOP"] = new ClassName("WS-READING & VOCABULARY WORKSHOP", "Reading", ClassType.Reading);
            classes["WS-CONVERSATION WORKSHOP"] = new ClassName("WS-CONVERSATION WORKSHOP", "Conversation", ClassType.Conversation);

            //management classes
            classes["PF-PROGRESS FOLLOW-UP"] = new ClassName("PF-PROGRESS FOLLOW-UP", "Progress Follow-up", ClassType.ProgressFollowup);
            classes["FC-CENTRE"] = new ClassName("FC-CENTRE", "First Class", ClassType.FirstClass);
            
            foreach (var keyValuePair in classes)
            {
                ClassName cn = ClassNameParser.ParseClassName(keyValuePair.Key);

                Assert.AreEqual(cn.FullName, keyValuePair.Value.FullName);
                Assert.AreEqual(cn.Name, keyValuePair.Value.Name);
                Assert.AreEqual(cn.Type, keyValuePair.Value.Type);
            }
        }

        /// <summary>
        /// Page on which reserved classes are shown.
        /// All examples in this test are from this page.
        /// </summary>
        [TestMethod]
        public void ReservedClassesParser()
        {
            Dictionary<String, ClassName> classes = new Dictionary<string, ClassName>();

            //group classes
            classes["CC - GC 8 - RED"] = new ClassName("CC - GC 8 - RED", "Red", ClassType.Group);
            classes["CC - GC 8 - ORANGE"] = new ClassName("CC - GC 8 - ORANGE", "Orange", ClassType.Group);

            //club classes
            classes["CA - ART CLUB"] = new ClassName("CA - ART CLUB", "Art", ClassType.Club);            

            //workshops
            classes["WS - GRAMMAR WORKSHOP"] = new ClassName("WS - GRAMMAR WORKSHOP", "Grammar", ClassType.Grammar);
            classes["WS - WRITING WORKSHOP"] = new ClassName("WS - WRITING WORKSHOP", "Writing", ClassType.Writing);
            classes["WS - READING & VOCABULARY"] = new ClassName("WS - READING & VOCABULARY", "Reading", ClassType.Reading);
            classes["WS - CONVERSATION WORKSHOP"] = new ClassName("WS - CONVERSATION WORKSHOP", "Conversation", ClassType.Conversation);

            foreach (var keyValuePair in classes)
            {
                ClassName cn = ClassNameParser.ParseClassName(keyValuePair.Key);

                Assert.AreEqual(cn.FullName, keyValuePair.Value.FullName);
                Assert.AreEqual(cn.Name, keyValuePair.Value.Name);
                Assert.AreEqual(cn.Type, keyValuePair.Value.Type);
            }
        }

        /// <summary>
        /// Page on which classes are being reserved.
        /// All examples in this test are from this page.
        /// </summary>
        [TestMethod]
        public void AvailableClassesParser()
        {
            Dictionary<String, ClassName> classes = new Dictionary<string, ClassName>();

            //group classes
            classes["CC - GC 8 - RED"] = new ClassName("CC - GC 8 - RED", "Red", ClassType.Group);
            classes["CC - GC 8 - ORANGE"] = new ClassName("CC - GC 8 - ORANGE", "Orange", ClassType.Group);

            //club classes
            classes["CA - ART CLUB"] = new ClassName("CA - ART CLUB", "Art", ClassType.Club);

            //workshops
            classes["WS - GRAMMAR WORKSHOP"] = new ClassName("WS - GRAMMAR WORKSHOP", "Grammar", ClassType.Grammar);
            classes["WS - WRITING WORKSHOP"] = new ClassName("WS - WRITING WORKSHOP", "Writing", ClassType.Writing);
            classes["WS - READING & VOCABULARY"] = new ClassName("WS - READING & VOCABULARY", "Reading", ClassType.Reading);
            classes["WS - CONVERSATION WORKSHOP"] = new ClassName("WS - CONVERSATION WORKSHOP", "Conversation", ClassType.Conversation);

            foreach (var keyValuePair in classes)
            {
                ClassName cn = ClassNameParser.ParseClassName(keyValuePair.Key);

                Assert.AreEqual(cn.FullName, keyValuePair.Value.FullName);
                Assert.AreEqual(cn.Name, keyValuePair.Value.Name);
                Assert.AreEqual(cn.Type, keyValuePair.Value.Type);
            }
        }
    }
}
